﻿<phone:PhoneApplicationPage 
    x:Class="Coding4Fun.ZuneDataViewer.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="False"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    x:Name="Main"
    DataContext="{Binding MainModel, Source={StaticResource Locator}}"
    xmlns:mdls="clr-namespace:Coding4Fun.ZuneDataViewer.Models"
    xmlns:helpers="clr-namespace:Coding4Fun.ZuneDataViewer.Helpers">

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="ImageHeader">
            <Image Source="/Images/zunedv.png"></Image>
        </DataTemplate>
        <helpers:BooleanToVisibilityConverter x:Key="bvConverter">
            
        </helpers:BooleanToVisibilityConverter>
    </phone:PhoneApplicationPage.Resources>
    
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <controls:Pivot TitleTemplate="{StaticResource ImageHeader}" Background="White" Foreground="Black" SelectionChanged="mainPanel_SelectionChanged"  x:Name="mainPanel">
            <controls:PivotItem Header="{Binding ZuneName}">
                <Grid>
                    <ScrollViewer>
                        <Grid>
                            <Image Source="/Images/default_bg.png" Height="199" HorizontalAlignment="Left" Margin="16,8,0,0" Stretch="Fill" VerticalAlignment="Top" Width="421" />
                            <Image Source="{Binding BackgroundImage}" Height="199" HorizontalAlignment="Left" Margin="16,8,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="421" />
                            <Image Stretch="Uniform" Source="{Binding ProfileImage}" Height="134" Width="129" Margin="39,38,288,462"></Image>
                            <Grid Background="Black" Height="49" HorizontalAlignment="Left" Margin="16,191,0,0" Name="grid1" VerticalAlignment="Top" Width="421">
                                <TextBlock Text="{Binding PlayCount}" Foreground="White" Margin="13,10,19,9"></TextBlock>
                            </Grid>
                            <TextBlock Foreground="Black" Style="{StaticResource PhoneTextExtraLargeStyle}" Height="49" HorizontalAlignment="Left" Margin="16,256,0,0" Name="textBlock1" Text="{Binding RealName}" VerticalAlignment="Top" Width="416" />
                            <TextBlock Height="30" HorizontalAlignment="Left" Margin="16,307,0,0" Name="textBlock2" Text="{Binding Status}" VerticalAlignment="Top" Width="416" />
                            <TextBlock Height="30" Margin="16,477,26,127" Width="413" Text="{Binding Location}"></TextBlock>
                            <TextBlock Height="30" HorizontalAlignment="Left" Margin="16,440,0,0" Name="textBlock3" Text="From:" FontWeight="Bold" VerticalAlignment="Top" />
                            <TextBlock Height="30" Margin="16,400,23,204" Text="{Binding LastUpdate}" Width="413" />
                            <TextBlock FontWeight="Bold" Height="30" HorizontalAlignment="Left" Margin="16,363,0,0" Name="textBlock4" Text="Last updated:" VerticalAlignment="Top" />
                            <TextBlock TextWrapping="Wrap" Height="221" Margin="16,555,26,-142" Text="{Binding Bio}" Width="413" />
                            <TextBlock FontWeight="Bold" Height="30" HorizontalAlignment="Left" Margin="16,518,0,0" Name="textBlock5" Text="Bio:" VerticalAlignment="Top" />
                        </Grid>
                    </ScrollViewer>
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="Badges">
                <ListBox ItemsSource="{Binding Badges}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="16,0,16,10">
                                <Image Height="75" Source="{Binding Path=Image}" HorizontalAlignment="Left" Stretch="Uniform" Width="75" />
                                <TextBlock Foreground="Black" FontWeight="Bold" Text="{Binding Path=Type}" Margin="118,0,0,0"></TextBlock>
                                <TextBlock Foreground="Black" Text="{Binding Path=Artist}" Margin="118,42,0,0"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>
            
            <controls:PivotItem Header="Recent" >
                <ListBox ItemsSource="{Binding RecentPlaylist}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="16,0,16,10">
                                <Image Height="100" Source="{Binding Path=AlbumArt}" HorizontalAlignment="Left" Stretch="Uniform" Width="100" />
                                <TextBlock Foreground="Black" FontSize="{StaticResource PhoneFontSizeLarge}" Text="{Binding Path=Title}" Margin="118,0,0,0"></TextBlock>
                                <TextBlock Foreground="Black" Text="{Binding Path=Artist}" Margin="118,42,0,0"></TextBlock>
                                <TextBlock Foreground="Black" Text="{Binding Path=Album}" Margin="118,67,0,0"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>

            <controls:PivotItem Header="Most Played">
                <ListBox ItemsSource="{Binding MostPlayed}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="16,0,16,10">
                                <Image Height="100" Source="{Binding Path=ArtistImage}" HorizontalAlignment="Left" Stretch="Uniform" Width="100" />
                                <TextBlock Foreground="Black" FontSize="{StaticResource PhoneFontSizeLarge}" Text="{Binding Path=Name}" Margin="118,0,0,0"></TextBlock>
                                <TextBlock Foreground="Black" Text="{Binding Path=Genre}" Margin="118,42,0,0"></TextBlock>
                                <TextBlock Foreground="Black" Text="{Binding Path=Playcount}" Margin="118,67,0,0"></TextBlock>
                                <Grid Background="#EB462E" Width="300" Margin="118,100,0,10" Visibility="{Binding Path=HasRadio,Converter={StaticResource bvConverter}}">
                                    <Image Height="16" Width="16" Source="/Images/radio.png" Margin="10,0,0,0" HorizontalAlignment="Left"></Image>
                                    <TextBlock Text="HAS A RADIO CHANNEL" Margin="40,0,0,0"></TextBlock>
                                </Grid>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>

            <controls:PivotItem Header="Favorites">
                <ListBox ItemsSource="{Binding Favorites}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="16,0,16,10">
                                <Image Margin="0,0,0,0" Source="{Binding Path=ArtistImage}" HorizontalAlignment="Left" Stretch="Uniform" />
                                <Grid Margin="0,290,0,0" Background="#EB462E" Height="160">
                                    <Image HorizontalAlignment="Left" Margin="15,0,0,0" Height="100" Source="{Binding Path=AlbumImage}" Stretch="Uniform" Width="100" />
                                    <TextBlock Margin="130,20,0,0" Foreground="Black" FontSize="25" FontWeight="Bold" Text="{Binding Path=Title}"></TextBlock>
                                    <TextBlock Margin="130,50,0,0" Foreground="Black" FontSize="15" Text="{Binding Path=ArtistName}"></TextBlock>
                                    <TextBlock Margin="130,70,0,0" Foreground="Black" FontSize="15" Text="{Binding Path=AlbumName}"></TextBlock>
                                    <TextBlock Margin="130,90,0,0" Foreground="Black" FontSize="15" Text="{Binding Path=Length}"></TextBlock>
                                    <Grid Height="40" Background="Red" Width="180" Margin="0,120,0,0" Visibility="{Binding Path=IsExplicit,Converter={StaticResource bvConverter}}">
                                        <Image Height="16" Width="16" Source="/Images/warn.png" Margin="10,0,0,0" HorizontalAlignment="Left"></Image>
                                        <TextBlock Foreground="White" Text="EXPLICIT" Margin="30,0,0,0"></TextBlock>
                                    </Grid>
                                </Grid>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>

            <controls:PivotItem Header="Friends">
                <ListBox ItemsSource="{Binding Friends}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Image Source="/Images/default_bg.png" Height="199" HorizontalAlignment="Left" Margin="16,8,0,0" Stretch="Fill" VerticalAlignment="Top" Width="421" />
                                <Image Source="{Binding BackgroundImage}" Height="199" Stretch="Fill" Width="421" />
                                <Image Stretch="Uniform" Source="{Binding ProfileImage}" Height="134" Width="129" Margin="0,0,200,35"></Image>
                                
                                <Grid Background="Black" Height="49" HorizontalAlignment="Left" Margin="16,191,0,0" VerticalAlignment="Top" Width="421">
                                    <TextBlock Text="{Binding Playcount}" Foreground="White" Margin="13,10,19,9"></TextBlock>
                                </Grid>

                                <TextBlock Text="{Binding Name}" HorizontalAlignment="Right" Foreground="White" FontSize="26" FontWeight="Bold" Margin="0,194,10,0"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>